"""
This file is part of GSBEdit. For copyright and licensing information, please
see gsbedit.py in the GSBEdit base directory.
"""


import ConfigParser
import os.path
import game_data.config_file as cf


class Module(cf.ConfigFile):
    def __init__(self, filename=None):
        cf.ConfigFile.__init__(self, filename)
    
    
    def create_sections(self):
        self.data.add_section('config')
        self.data.add_section('dataitems')
        self.data.add_section('gsbedit')
                

    def load_template(self, template_name, template):
        self.set_value('gsbedit', 'module_type', template_name)
        def_tag = 'default_'
        def_tag_len = len(def_tag)
        
        for value_name, value in template['defaults'].iteritems():
            self.set_value('config', value_name, value)

    
    def __repr__(self):
        return "module.Module('%s')" % (self.filename)
    
    
    def __str__(self):
        return "Module<%s>" % self.get_name()
        
